package ConverterDemo;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class InputStreamReaderDemo {
	
	public static void main(String[] args) {
		
		InputStream in = System.in;
		
		BufferedReader br = null;
		BufferedWriter bw = null;
		try {
			br = new BufferedReader(new InputStreamReader(in));
			bw = new BufferedWriter(new FileWriter("b.txt"));
			String line = null;
			while((line = br.readLine()) != null)
			{
				if("exit".equals(line)) {
					break;
				}
				bw.write(line);
				bw.newLine();
				bw.flush();
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if(bw != null)
					bw.close();
				if(br != null)
					br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}	
	}
}
